package com.example.demo.common;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * 统一异常处理
 */
@ControllerAdvice
@ResponseBody
public class ResponseException {


    @ExceptionHandler(Exception.class) //这里也可以根据实际情况，填写不同的异常
    public AjaxResult nullException(Exception e) {
        return AjaxResult.error(e.getMessage(), -1);
    }

}
